package FlowGraph.Nodes;

import antlr.collections.AST;

import java.util.*;

import db.ClassData;
import util.Line;
import FlowGraph.FlowGraphNode;

//////////////////////////////////////////////////////////////////////////
//// InnerClassFlowGraphNode
/**

@author Ivan Jeukens
@version v 0.1 30/04/2002
*/
public class InnerClassNode extends FlowGraphNode  {

    public static final int LOCAL = 1;
    public static final int ANONYMOUS = 2;

    public InnerClassNode(AST statement) {
        super(statement, INNER_CLASS);
    }

    public InnerClassNode(AST statement, ClassData owner, int type) {
        super(statement, INNER_CLASS);
        _classType = type;
        _parse(owner);
    }

    ///////////////////////////////////////////////////////////////////
    ////                        public methods                     ////
    
    public void setClassType(int type) {
        _classType = type;
    }

    public int getClassType() {
        return _classType;
    }

    public ClassData getClassInfo() {
        return _classInfo;
    }
    
    public LinkedList getCode() {
        return _classInfo.getCode();
    }
    public void setClassName(String name) {
        _className = name;   
    }
    
    public String getClassName() {
        return _className;
    }
    
    public void setClassInfo(ClassData info) {
        _classInfo = info;
    }
    
    public void setBegLine(Line l) {
        _begLine = l;
    }
    
    public Line getBegLine() {
        return _begLine;
    }
    
    public void setEndLine(Line l) {
        _endLine = l;
    }
    
    public Line getEndLine() {
        return _endLine;
    }

    ///////////////////////////////////////////////////////////////////
    ////                        private methods                    ////

    private void _parse(ClassData owner) {
        System.out.println("CLASSE INTERNA!!!!!!!!!!!!!!!!!!!!!!");
        
        /*
        if(_classType == ANONYMOUS) {
            AST v = _absTreeNode;
            v = v.getFirstChild();
            v = v.getNextSibling();
            v = v.getNextSibling();
            String name = v.getText();
            v = v.getNextSibling();
            v = v.getFirstChild();
            v = v.getFirstChild();
            v = v.getFirstChild();
            v = v.getNextSibling();
            // ObjBlock
            v = v.getNextSibling();

            _className = new String(owner.getName() + "." + name);
            _classInfo = new ClassData(null, _className, true, v);
            _classInfo.buildAnonymousClass();
        }
        else
        if(_classType == LOCAL) {
            AST v = _absTreeNode.getFirstChild();
            v = v.getNextSibling();
            _className = new String(owner.getName() + "." + v.getText());
            _classInfo = new ClassData(owner.getActorDB(), _className, _absTreeNode, 
                owner.getPackage(), true);
        }
        _classInfo.setImports(owner.getImports());
        _classInfo.setSuperClass(owner);
        owner.addInnerClass(_classInfo);
        */
    }

    ///////////////////////////////////////////////////////////////////
    ////                      private variables                    ////

    private String _className;
    private ClassData _classInfo;
    private int _classType;
    
    // para classes anonimas
    private Line _begLine;
    private Line _endLine;
}
